/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ca.jerg.config;

import java.awt.Color;

/**
 *
 * @author dave
 */
public class ErgConfigCanvas extends ErgConfig
{	
	/*
	 * Default cavnas settings.
	 */
	public static final double DEF_MAX_TIME = 60.0;
	public static final int DEF_MAX_WATT = 400;
	public static final boolean DEF_SHOW_GRIDS = true;
	public static final double DEF_X_AXIS_TICK_SPACE = 10.0;
	public static final double DEF_Y_AXIS_TICK_SPACE = 100.0;
	public static final Color DEF_DATA_LINE_COLOUR = Color.RED;
	public static final Color DEF_DATA_POINT_COLOUR = Color.BLUE;
	public static final float DEF_DATA_LINE_WIDTH = (float)0.75;
	public static final int DEF_DATA_POINT_RADIUS = 2;
	
	private final String ERG_CFG_CANVAS_STR = "ErgCfgCanvas: ";	
	
	public ErgConfigCanvas()
	{
		super("Canvas");
		
		String s;
		double d;	
		int i;
		boolean b;
		
		/*
		 * The first time this class is loaded there is no
		 * stored Work Details configuration.  If, that is
		 * the case then create a setup using the default
		 * values.
		 */
		
		d = config.getDouble(KEY_MAX_POINT_TIME,-1.0);
		if ( d == -1.0 )
			config.putDouble(KEY_MAX_POINT_TIME,DEF_MAX_TIME);

		i = config.getInt(KEY_MAX_POINT_WATT,-1);
		if ( i == -1 )
			config.putInt(KEY_MAX_POINT_WATT,DEF_MAX_WATT);
		
		d = config.getDouble(KEY_X_AXIS_TICK_SPACE,-1.0);
		if ( d == -1.0 )
			config.putDouble(KEY_X_AXIS_TICK_SPACE,DEF_X_AXIS_TICK_SPACE);
		
		d = config.getDouble(KEY_Y_AXIS_TICK_SPACE,-1.0);
		if ( d == -1.0 )
			config.putDouble(KEY_Y_AXIS_TICK_SPACE,DEF_Y_AXIS_TICK_SPACE);
		
		i = config.getInt(KEY_DATA_LINE_COLOUR,-1);
		if ( i == -1 )
			config.putInt(KEY_DATA_LINE_COLOUR,DEF_DATA_LINE_COLOUR.getRGB());
		
		i = config.getInt(KEY_DATA_POINT_COLOUR,-1);
		if (  i == -1 )
			config.putInt(KEY_DATA_POINT_COLOUR,DEF_DATA_POINT_COLOUR.getRGB());

		d = config.getDouble(KEY_DATA_LINE_WIDTH,-1.0);
		if ( d == -1.0 )
			config.putDouble(KEY_DATA_LINE_WIDTH,DEF_DATA_LINE_WIDTH);
		
		i = config.getInt(KEY_DATA_POINT_RADIUS,-1);
		if ( i == -1 )
			config.putInt(KEY_DATA_POINT_RADIUS,DEF_DATA_POINT_RADIUS);
	}
	
	public void defaults()
	{	
		config.putDouble(KEY_MAX_POINT_TIME,DEF_MAX_TIME);
		config.putInt(KEY_MAX_POINT_WATT,DEF_MAX_WATT);
		config.putBoolean(KEY_SHOW_GRIDS,DEF_SHOW_GRIDS);
		config.putDouble(KEY_X_AXIS_TICK_SPACE,DEF_X_AXIS_TICK_SPACE);
		config.putDouble(KEY_Y_AXIS_TICK_SPACE,DEF_Y_AXIS_TICK_SPACE);
		config.putInt(KEY_DATA_LINE_COLOUR,DEF_DATA_LINE_COLOUR.getRGB());
		config.putInt(KEY_DATA_POINT_COLOUR,DEF_DATA_POINT_COLOUR.getRGB());
		config.putDouble(KEY_DATA_LINE_WIDTH,DEF_DATA_LINE_WIDTH);
		config.putInt(KEY_DATA_POINT_RADIUS,DEF_DATA_POINT_RADIUS);
	}

	public void put( String key, String value )
	{
		config.put(key,value);
	}

	public void putBoolean( String key, boolean value )
	{
		config.putBoolean(key,value);
	}

	public void putDouble( String key, double value )
	{
		config.putDouble(key,value);
	}

	public void putInt( String key, int value )
	{
		config.putInt(key,value);
	}

	public String getString( String key, String def )
	{
		return config.get(key,def);
	}

	public boolean getBoolean( String key, boolean def )
	{
		return config.getBoolean(key,def);
	}

	public double getDouble( String key, double def )
	{
		return config.getDouble(key,def);
	}

	public int getInt( String key, int def )
	{
		return config.getInt(key,def);
	}
}
